import { LoginAction } from '@/types/store'
import { getToken } from '@/utils/storage'

const initialState = getToken()
const login = (state = initialState, action: LoginAction) => {
  if (action.type === 'login/login') {
    return action.payload
  }
  if (action.type === 'login/logout') {
    return {
      token: '',
      refresh_token: ''
    }
  }
  return state
}
export default login